package com.allwees.bs.c.module.user.entity;

import com.allwees.bs.c.module.base.entity.JpaBaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;

/**
 * 记录用户点击忘记密码的过期时间
 *
 * @author jy2016
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Entity()
@Table(name = "usr_retrieve_passwd")
public class RetrievePasswdEntity extends JpaBaseEntity {
	@Column(length = 64)
	private String userUuid;

	private String userEmail;

	private String sid;

	private boolean used;

	private Long overtime;

	public RetrievePasswdEntity(String userUuid, String userEmail, String sid, long overtime) {
		this.userUuid = userUuid;
		this.userEmail = userEmail;
		this.sid = sid;
		this.overtime = overtime;
	}

	@PrePersist
	public void onCreate() {
		super.onCreate();
		this.used = false;
	}

	@Override
	@PreUpdate
	public void onUpdate() {
		super.onUpdate();
		this.used = true;
	}
}
